<template> 
    <div class="app-container">
        <!-- 公司信息-->
        <el-card shadow="never" class="standard-margin">
            <el-row>
                <el-col :span="4" :offset="7"><span class="font-title-medium">对账单信息</span></el-col>
            </el-row>
            <el-row>
                <el-col :span="4" :offset="6"><span class="font-title-medium">{{checkAmountDetail.storeSettlementStartTime}}-{{checkAmountDetail.storeSettlementEndTime}}</span></el-col>
            </el-row>
            <div class="form-container-border">
                <el-row>
                    <el-col :span="4" class="form-border form-left-bg font-small">商家名称</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.storeName}}</el-col>
                    <el-col :span="4" class="form-border form-left-bg font-small">合作平台</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.platformName}}</el-col>
                </el-row>
                <el-row>
                    <el-col :span="4" class="form-border form-left-bg font-small">地址</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.storeAdress}}</el-col>
                    <el-col :span="4" class="form-border form-left-bg font-small">地址</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.platformAdress}}</el-col>
                </el-row>
                <el-row>
                    <el-col class="form-border form-left-bg font-small" :span="4">电话</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.storeMobile}}</el-col>
                    <el-col class="form-border form-left-bg font-small" :span="4">电话</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.platformMobile}}</el-col>
                </el-row>
                <el-row>
                    <el-col class="form-border form-left-bg font-small" :span="4">结算周期</el-col>
                    <el-col class="form-border font-small" :span="8">{{checkAmountDetail.storeSettlementStartTime}}-{{checkAmountDetail.storeSettlementEndTime}}</el-col>
                    <el-col class="form-border form-left-bg font-small" :span="4">&nbsp;&nbsp;</el-col>
                    <el-col class="form-border font-small" :span="8">&nbsp;&nbsp;</el-col>
                </el-row>
            </div>
        </el-card>
        <el-card class="operate-container" shadow="never">
            <span>请认真核对本期对账单</span>
        </el-card>
        <!-- 对账单金额汇总-->
        <el-card class="operate-container" shadow="never">
            <span>订单总额：￥{{checkAmountDetail.totalOrderAmount}}   实付总额：￥{{checkAmountDetail.totalPayAmount}}
                优惠总额：￥{{checkAmountDetail.totalDiscountAmount}}   退款总额：￥{{checkAmountDetail.totalRefundAmount}}
                对账单金额：￥{{checkAmountDetail.totalCheckAmount}}</span>
        </el-card>
        <!-- 对账单表格-->
        <div class="table-container">
            <el-table ref="orderTable"
                      :data="list"
                      style="width: 100%;"
                      @selection-change="handleSelectionChange"
                      v-loading="listLoading" border>
                <el-table-column type="selection" width="60" align="center"></el-table-column>
                <el-table-column label="订单编号" width="180" align="center">
                    <template slot-scope="scope">{{scope.row.orderSn}}</template>
                </el-table-column>
                <el-table-column label="提交时间" width="180" align="center">
                    <template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template>
                </el-table-column>
                <el-table-column label="用户账号" align="center">
                    <template slot-scope="scope">{{scope.row.memberName}}</template>
                </el-table-column>
                <el-table-column label="订单金额" width="120" align="center">
                    <template slot-scope="scope">￥{{scope.row.orderAmount}}</template>
                </el-table-column>
                <el-table-column label="实付金额" width="120" align="center">
                    <template slot-scope="scope">￥{{scope.row.payAmount}}</template>
                </el-table-column>
                <el-table-column label="优惠金额" width="120" align="center">
                    <template slot-scope="scope">￥{{scope.row.discountAmount}}</template>
                </el-table-column>
                <el-table-column label="退款金额" width="120" align="center">
                    <template slot-scope="scope">￥{{scope.row.refundAmount}}</template>
                </el-table-column>
                <el-table-column label="对账单金额" width="120" align="center">
                    <template slot-scope="scope">￥{{scope.row.settleAmount}}</template>
                </el-table-column>
            </el-table>
        </div>
        <!-- 对账单分页-->
        <div class="pagination-container">
            <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    layout="total, sizes,prev, pager, next,jumper"
                    :current-page.sync="listQuery.pageNum"
                    :page-size="listQuery.pageSize"
                    :page-sizes="[5,10,15]"
                    :total="total">
            </el-pagination>
            <br>
        </div>
    </div>
</template>
<script>
    import {checkAmountDetail, checkAmountList} from '@/api/finance/finance'
    import {formatDate} from '@/utils/date';

    const defaultListQuery = {
        pageNum: 1,
        pageSize: 10,
        checkId: null
    };
    export default {
        name: "orderList",
        components: {},
        data() {
            return {
                checkAmountDetail: {},
                listQuery: Object.assign({}, defaultListQuery),
                listLoading: true,
                list: null,
                total: null,
                multipleSelection: [],
            }
        },
        created() {
            this.settlementId = this.$route.query.id;
            this.getList();
            this.getDetail();
        },
        filters: {
            formatCreateTime(time) {
                let date = new Date(time);
                return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
            },
        },
        methods: {
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            handleSizeChange(val) {
                this.listQuery.pageNum = 1;
                this.listQuery.pageSize = val;
                this.getList();
            },
            handleCurrentChange(val) {
                this.listQuery.pageNum = val;
                this.getList();
            },
            getList() {
                this.listLoading = true;
                this.listQuery.checkId = this.settlementId;
                checkAmountList(this.listQuery).then(response => {
                    this.listLoading = false;
                    this.list = response.data.records;
                    this.total = response.data.total;
                });
            },
            getDetail() {
                checkAmountDetail({settlementId: this.settlementId}).then(response => {
                    this.checkAmountDetail = response.data;
                });
            },
        }
    }
</script>
<style scoped>
    .input-width {
        width: 203px;
    }

    .detail-container {
        position: absolute;
        left: 0;
        right: 0;
        width: 1080px;
        padding: 35px 35px 15px 35px;
        margin: 20px auto;
    }

    .standard-margin {
        margin-top: 15px;
    }

    .form-border {
        border-right: 1px solid #DCDFE6;
        border-bottom: 1px solid #DCDFE6;
        padding: 10px;
    }

    .form-container-border {
        border-left: 1px solid #DCDFE6;
        border-top: 1px solid #DCDFE6;
        margin-top: 15px;
    }

    .form-left-bg {
        background: #F2F6FC;
    }
</style>


